// 如果是长度为n的环形，就将两个n长度的拼在一起，成为2n长度的直线
// 从1到n枚举开头位置
#include <bits/stdc++.h>
using namespace std;
const int N = 210, M = N << 1, INF = 0x3f3f3f3f;
int n;
int w[M], s[M];
int f[M][M], g[M][M];
int main() {
  cin >> n;
  for (int i = 0; i <= n; ++i) {
    cin >> w[i];
    w[i + n] = w[i];
  }
  for (int i = 0; i <= n << 1; ++i) {
    s[i] = s[i - 1] + w[i];
  }
  memset(f, -0x3f, sizeof f);
  memset(g, 0x3f, sizeof g);

  for (int len = 1; len <= n; ++len) {
    for (int l = 1, r; r = l + len - 1, r < n << 1; ++l) {
      if (len == 1)
        f[l][l] = g[l][l] = 0;
      else {
        for (int k = l; k + 1 <= r; ++k) {
          f[l][r] = max(f[l][r], f[l][k] + f[k + 1][r] + s[r] - s[l - 1]);
          g[l][r] = min(g[l][r], g[l][k] + g[k + 1][r] + s[r] - s[l - 1]);
        }
      }
    }
  }
  int minv = INF, maxv = -INF;
  for (int l = 1; l <= n; ++l) {
    minv = min(minv, g[l][l + n - 1]);
    maxv = max(maxv, f[l][l + n - 1]);
  }
  cout << minv << endl << maxv << endl;
}
